/**  
 * Copyright (c) 2010 University of Pennsylvania.
 *     All rights reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an "AS
 *  IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 *  express or implied.  See the License for the specific language
 *  governing permissions and limitations under the License.
 *
 */
 
typedef struct _MULTICAST_NODE {    // structure of a multicast tree
  uint8_t send_here;                // if 1, message needs to be delivered to this internal node

  ADDRESS *path;                    // path to get to this internal node
  uint8_t path_len;                 // its address is the last on the pathvector

  uint8_t child_count;              // subtrees
  struct _MULTICAST_NODE **children;

  uint8_t marshal_size;  // how large is this subtree when marshalled (for cost model)
  uint8_t node_level;    // level of node if send here or no children (for cost model)
  uint8_t multiplicity;  // with how many other sources are we joining there (for cost model)
} MULTICAST_NODE;

void multicast_insertpath(MULTICAST_NODE **p, ADDRESS *path, uint8_t path_len, uint8_t node_level,
  uint8_t multiplicity);
void marshal_multicast(uint8_t **pos, MULTICAST_NODE *n, uint8_t level);
void unmarshal_multicast(uint8_t **pos, MULTICAST_NODE **n, uint8_t level);
void multicast_free(MULTICAST_NODE *n);

void multicast_print(MULTICAST_NODE *n, uint8_t level);

